	// Program for regressing subgroup heterogeneous effects
	cap program drop heteffreg
		program define heteffreg
		syntax varlist [if], FIle(string) [replace DRop(varlist) keep(varlist) ctitle(string) sort(varlist) ]
		areg `varlist' `if', a(Group_detailed) cluster(School_blind) 
		local r_sq: display %9.3f e(r2_a)
		if "`replace'" == "replace" {
			outreg2 using "`file'.xls", tex(pretty) replace dec(3) drop(`drop') keep(`keep') sortvar(`sort') ctitle("`ctitle'") addtext("Adj-R-Squared", "`r_sq'", "Group*Year*Cohort FE", "Yes") nonotes lab nocons dta
		}
		else {
			outreg2 using "`file'.xls", tex(pretty) append dec(3) drop(`drop') keep(`keep') sortvar(`sort') ctitle("`ctitle'") addtext("Adj-R-Squared", "`r_sq'", "Group*Year*Cohort FE", "Yes") nonotes lab  nocons dta
		}
	end	
	use "$dir\DataSCLB", clear	
	// Estimation
	heteffreg EL_EGRA_PCA_Index $treat , file($output/Table5) keep(MT_* CCT_*) ctitle("Base Model") replace	

	heteffreg EL_EGRA_PCA_Index $treat $students_d, file($output/Table5) keep(MT_* CCT_*) ctitle("Students")
	heteffreg EL_EGRA_PCA_Index $treat $teachers_d, file($output/Table5) keep(MT_* CCT_*) ctitle("Teachers")
	heteffreg EL_EGRA_PCA_Index $treat $students_d $teachers_d, file($output/Table5) keep(MT_* CCT_*) ctitle("Teachers")

	use "$output/Table5_dta.dta", clear
	save "$output/Table5.dta", replace
	
	cap erase "$output/Table5.xls"
	cap erase "$output/Table5.tex"
	cap erase "$output/Table5.txt"
	cap erase "$output/Table5_dta.dta"